#include "serversettingsdialog.h"
#include "ui_serversettingsdialog.h"

ServerSettingsDialog::ServerSettingsDialog(QString& address, QString& portNum, QString& userId, QString& password, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ServerSettingsDialog)
{
    ui->setupUi(this);

    mAddress = address;
    mPortNum = portNum;
    mUserId = userId;
    mPassword = password;

    ui->addressEdit->setText(mAddress);
    ui->portNumEdit->setText(mPortNum);
    ui->userIdEdit->setText(mUserId);
    ui->passwordEdit->setText(mPassword);

    //ui->addressEdit->setInputMask("000.000.000.000");
    ui->portNumEdit->setInputMask("00000");
}

ServerSettingsDialog::~ServerSettingsDialog()
{
    delete ui;
}

QString ServerSettingsDialog::address()
{
    return mAddress;
}

QString ServerSettingsDialog::portNum()
{
    return mPortNum;
}

QString ServerSettingsDialog::userId()
{
    return mUserId;
}

QString ServerSettingsDialog::password()
{
    return mPassword;
}

void ServerSettingsDialog::accept()
{
    QString address = ui->addressEdit->text();
    QString portNum = ui->portNumEdit->text();
    QString userId = ui->userIdEdit->text();
    QString password = ui->passwordEdit->text();
    if (address.length() && portNum.length() && userId.length() && password.length()) {
        mAddress = address;
        mPortNum = portNum;
        mUserId = userId;
        mPassword = password;

        QDialog::accept();
    }
}
